﻿@model SimpleTaskManager.Domain.Entities.Task

@using SimpleTaskManager.WebUI.HtmlHelpers

@{
    ViewBag.Title = "Edit task";
}

<h2>Edit task</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Task</legend>

        @Html.HiddenFor(model => model.TaskID)

        @Html.HiddenFor(model => model.StartDate)

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.EndDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.EndDate)
            @Html.ValidationMessageFor(model => model.EndDate)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LeaderId)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.LeaderId, 
            (ViewBag.UserList as IEnumerable<SimpleTaskManager.Domain.Entities.User>).Select(
                u => new SelectListItem{Text = u.LastName + ", " + u.FirstName, 
                    Value = u.UserID.ToString(),
                    Selected = (u.UserID == Model.LeaderId)}))
            @Html.ValidationMessageFor(model => model.LeaderId)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.GroupSize)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.GroupSize)
            @Html.ValidationMessageFor(model => model.GroupSize)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Status)
        </div>
        <div class="editor-field">
            @Html.EnumDropDownListFor(model => model.Status)
            @Html.ValidationMessageFor(model => model.Status)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Rating)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Rating)
            @Html.ValidationMessageFor(model => model.Rating)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <p style="clear: left">
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Details", new { id = (Model.ParentTask ?? Model).TaskID })
</div>
